﻿using NUnit.Framework;

using Payroll.Biz.Legacy.Models;
using System;

namespace Payroll.Biz.Legacy.Test.GPT
{
    /// <summary>
    /// Prompt:
    /// Here is a C# class:
    /// [Employee.cs]
    /// I want you to help me write the assertion equals method by using NUnit.
    /// </summary>
    [TestFixture]
    public class GenerateEquals1
    {
        [Test]
        public void Equals_ShouldReturnTrueForSameObject()
        {
            Guid id = Guid.NewGuid();
            MockClassification classification = new MockClassification();
            Employee employee = new Employee(id, "123 Main St", classification)
            {
                Name = "John Doe",
                Schedule = new MockSchedule(),
                Method = new MockMethod(),
                Affiliation = new MockAffiliation()
            };

            Assert.IsTrue(employee.Equals(employee));
        }

        [Test]
        public void Equals_ShouldReturnTrueForEqualObjects()
        {
            Guid id = Guid.NewGuid();
            MockClassification classification = new MockClassification();
            Employee employee1 = new Employee(id, "123 Main St", classification)
            {
                Name = "John Doe",
                Schedule = new MockSchedule(),
                Method = new MockMethod(),
                Affiliation = new MockAffiliation()
            };

            Employee employee2 = new Employee(id, "123 Main St", classification)
            {
                Name = "John Doe",
                Schedule = new MockSchedule(),
                Method = new MockMethod(),
                Affiliation = new MockAffiliation()
            };

            Assert.IsTrue(employee1.Equals(employee2));
        }

        [Test]
        public void Equals_ShouldReturnFalseForDifferentObjects()
        {
            MockClassification classification1 = new MockClassification();
            MockClassification classification2 = new MockClassification();
            Employee employee1 = new Employee(Guid.NewGuid(), "123 Main St", classification1)
            {
                Name = "John Doe",
                Schedule = new MockSchedule(),
                Method = new MockMethod(),
                Affiliation = new MockAffiliation()
            };

            Employee employee2 = new Employee(Guid.NewGuid(), "456 Elm St", classification2)
            {
                Name = "Jane Doe",
                Schedule = new MockSchedule(),
                Method = new MockMethod(),
                Affiliation = new MockAffiliation()
            };

            Assert.IsFalse(employee1.Equals(employee2));
        }
    }

    // Mock classes for testing purposes  
    public class MockClassification : IPaymentClassification
    {
        public decimal CalculatePay(Paycheck paycheck) => 0;
    }

    public class MockSchedule : IPaymentSchedule
    {
        public bool IsPayDate(DateTime date) => true;

        public DateTime GetPayPeriodStartDate(DateTime date) => date;
    }

    public class MockMethod : IPaymentMethod
    {
        public void Pay(Paycheck paycheck)
        {
        }
    }

    public class MockAffiliation : IAffiliation
    {
        public decimal CalculateDeductions(Paycheck paycheck) => 0;
    }
}
